package org.budo.support.java.collection.wrapper;

import java.util.ArrayList;
import java.util.Collection;

import org.budo.support.lang.util.ListUtil;
import org.budo.support.slf4j.Slf4j;
import org.slf4j.Logger;

import com.alibaba.fastjson.JSON;

/**
 * @author lmw
 */
public class NiceToStringListWrapper extends ListWrapper {
    private static final long serialVersionUID = -4107198140825299409L;

    private static final Logger log = Slf4j.getLogger();

    public NiceToStringListWrapper(Collection collection) {
        super(new ArrayList(collection));
    }

    public NiceToStringListWrapper(Object[] array) {
        this(ListUtil.toList(array));
    }

    public String toString() {
        try {
            return JSON.toJSONString(this.getCollection());
        } catch (Exception e) {
            log.error("" + e);
            return super.toString();
        }
    }
}